package com.songlanyun.modules.rabbitmq.interactmsg.impl;

import com.songlanyun.common.enums.PrivateMessageConstant;
import com.songlanyun.modules.message.model.to.MessageTO;
import com.songlanyun.modules.rabbitmq.interactmsg.IInteractMsgService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;


@Service("iInteractMsgService")
public class InteractMsgServiceImpl implements IInteractMsgService {

    private Map<Integer, IInteractMsgService> iServices = new HashMap<>();

    public InteractMsgServiceImpl(IInteractMsgService seckillInteractService,
                                  IInteractMsgService groupBuyInteractService,
                                  IInteractMsgService refillInteractService,
                                  IInteractMsgService orderInteractService,
                                  IInteractMsgService logisticsInteractService,
                                  IInteractMsgService rightsInteractService,
                                  IInteractMsgService opusBbsInteractService,
                                  IInteractMsgService concernInteractService,
                                  IInteractMsgService checkInteractService,
                                  IInteractMsgService areaAgentCheckInteractService
                                  ) {
        //活动消息
        iServices.put(PrivateMessageConstant.ModelType.SECKILL.getCode(), seckillInteractService);
        iServices.put(PrivateMessageConstant.ModelType.GROUP_BUY.getCode(), groupBuyInteractService);
        //支付消息
        iServices.put(PrivateMessageConstant.ModelType.REFILL_PAY_SUCCESS.getCode(), refillInteractService);
        iServices.put(PrivateMessageConstant.ModelType.ORDER_PAY_SUCCESS.getCode(), orderInteractService);
        //物流消息
        iServices.put(PrivateMessageConstant.ModelType.LOGISTICS.getCode(), logisticsInteractService);
        //售后消息
        iServices.put(PrivateMessageConstant.ModelType.REFUND.getCode(), rightsInteractService);
        //互动消息
        iServices.put(PrivateMessageConstant.ModelType.OPUS_LIKE_SHARE_COMMENT.getCode(), opusBbsInteractService);
        iServices.put(PrivateMessageConstant.ModelType.CONCERNS.getCode(), concernInteractService);
        iServices.put(PrivateMessageConstant.ModelType.CHECK.getCode(), checkInteractService);
        //系统消息
        iServices.put(PrivateMessageConstant.ModelType.CARRIER_AUDIT.getCode(), areaAgentCheckInteractService);

    }

    @Override
    public void savePrivateMsg(MessageTO to) {
        Integer modelType = to.getModelType().getCode();
        if (iServices.containsKey(modelType)) {
            iServices.get(modelType).savePrivateMsg(to);
        }

    }
}
